package com.flrjcx.controller;

import com.flrjcx.common.enums.ResultCodeEnum;
import com.flrjcx.common.model.UserModel;
import com.flrjcx.common.model.result.ResponseData;
import com.flrjcx.service.LoginService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 登录控制
 * @author Flrjcx
 */
@RestController
@RequestMapping("/ziliHouse")
@Slf4j
public class LoginController {
    @Resource
    private LoginService loginService;

    @PostMapping("/login")
    public ResponseData login(UserModel userModel) {
        try {
            ResponseData responseData = loginService.verifyLoginBeforeAll(userModel);
            return responseData;
        }catch (Exception e){
            log.error("/login error"+e.getMessage());
            return ResponseData.buildErrorResponse(ResultCodeEnum.CODE_SYSTEM_ERROR.getCode(), e.getMessage());
        }
    }
}
